<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/popen.css" />
<script type="text/javascript" src="js/global.js"></script>
<script type="text/javascript">
//操作选中的图片,type可以是add或del
function qg_setpic(id,row)
{
	if(id)
	{
		if(row)
		{
			var startid = (5*(row-1))+1;
			var cbox0 = document.getElementById("check_"+startid);
			if(cbox0.checked == false)
			{
				for(t=startid;t<=id;t++)
				{
					document.getElementById("check_"+t).checked = true;
				}
			}
			else
			{
				for(t=startid;t<=id;t++)
				{
					document.getElementById("check_"+t).checked = false;
				}
			}
		}
		else
		{
			var cbox = document.getElementById("check_"+id);
			if(cbox.checked == false)
			{
				cbox.checked = true;
			}
			else
			{
				cbox.checked = false;
			}
		}
	}
	var mytype = document.getElementById("popen_value_type").value;
	if(!mytype)
	{
		mytype = "mark";
	}
	var msg_array = new Array();
	var cv = document.getElementsByTagName("input");
	var m = 0;
	for(var i=0; i<cv.length; i++)
	{
		if(cv[i].type.toLowerCase() == "checkbox")
		{
			if(cv[i].checked)
			{
				var mid = cv[i].value;
				if(mid)
				{
					var m_id = "input_message_"+mid;
					var v = document.getElementById(m_id).value;
					if(v)
					{
						var vv = v.split("|,|");
						if(mytype == "thumb")
						{
							msg_array[m] = "<div style='text-align:center;'><img src='"+vv[0]+"' border='0'></div>";
						}
						else if(mytype == "mark")
						{
							msg_array[m] = "<div style='text-align:center;'><img src='"+vv[1]+"' border='0'></div>";
						}
						else
						{
							msg_array[m] = "<div style='text-align:center;'><img src='"+vv[2]+"' border='0'></div>";
						}
						m++;
					}
				}
			}
		}
	}
	msg_array.reverse(); //数组倒序
	var message = msg_array.join("<div>&nbsp;</div>");
	if(message)
	{
		document.getElementById("popen_msg").innerHTML = message;
	}
}

function check_upfile()
{
	uploading();
	
	var filePaths = document.getElementById("iframeUpload").files;
	var arrnum = filePaths.length;
	
	//限制上传文件类型
	for(i=0;i<arrnum;i++)
	{
		var poi = filePaths[i].name;
		var fileAccept = poi.split(".")[1];
		fileAccept=fileAccept.toLowerCase();
		if(fileAccept!="jpg" && fileAccept!="jpeg" && fileAccept!="gif" && fileAccept!="png")
		{
			tip_alert("包含非法文件类型!");
			return false;
		}
	}
	
	//限制上传图片数量
	if(arrnum>20)
	{
		tip_alert("一次最多只能选择20张图片")
		return false;
	}
}
function uploading()
{
	document.getElementById("upbtn").value="上传中...";
	document.getElementById("upbtn").disabled=true;
}
</script>

<!-- if($_SESSION[admin][editorid]==0 || $editor_btn) -->
<script>
function upload()
{
	var msg = document.getElementById("popen_msg").innerHTML;
	callback(msg);
}
</script>

<!-- elseif($_SESSION[admin][editorid]==1) -->
<script type="text/javascript" src="include/editorue/dialogs/internal.js"></script>
<script>
function save_pic()
{
	var msg = document.getElementById("popen_msg").innerHTML;
	editor.execCommand('insertHtml',msg);
}
dialog.onok = save_pic;
</script>
<!-- end -->

<style>
.xbutton {text-align:center;}
.xbutton a {font-size:12px; text-decoration:none; color:#333; border:1px solid #ddd; background:#f4f4f4; display:inline-block; padding:5px 18px; margin:0 4px;}
.xbutton a:hover {text-decoration:underline;}
.xbutton a.on {border:1px solid #6f7b8b; background:#6f7b8b; color:#fff;}
</style>
</head>
<body style="overflow-y:scroll;">
<table width="100%" cellpadding="0" cellspacing="1">
<tr>
	<form method="post" action="{:$mainlink}?file=open.addpic&act=addok&inputname={:$inputname}&sysgroupid={:$sysgroupid}{if($editor_btn)}&editor_btn={:$editor_btn}{end}" enctype="multipart/form-data" onsubmit="return check_upfile()">
	<td style="border-bottom:1px #D4D4D4 solid;">
        <input type="file" id="iframeUpload" name="iframeUpload[]" accept="image/jpeg,image/jpg,image/gif,image/png" multiple/>
		<input id="upbtn" type="submit" value="上传">
		<select id="popen_value_type" onchange="qg_setpic();">
			<option value="mark">水印图</option>
			<option value="thumb">缩略图</option>
			<option value="normal" selected>原图</option>
		</select>
		&nbsp; 一次最多只能上传<span style="color:red;">20</span>张图片！
	</td>
	</form>
</tr>
</table>
<div id="popen_msg" style="display:none"></div>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
	<!-- run:$i=1 -->
	<!-- $piclist AS $key=>$value -->
	<td style="text-align:center;width:16%;height:100px;cursor:pointer;" align="center"><img onclick="qg_setpic('{:$value[row_index]}')" src="{:$value[show_pic]}" width="90px" height="70px" border="0" /><br /><input style="margin:0;" id="check_{:$value[row_index]}" type="checkbox" name="pic_checkbox[]" value="{:$value[id]}" onclick="qg_setpic();"><input type="hidden" value="{:$value[input_message]}" id="input_message_{:$value[id]}" name="input_message_{:$value[id]}"><div style="height:16px; line-height:16px; overflow:hidden; margin-bottom:10px;">{:$value[tmpname]}</div></td>
    <!-- if($value[row_index]%5==0) --><th style="text-align:center;width:16%;height:100px;" align="center" onclick="qg_setpic('{:$value[row_index]}','{:$i}')" ><a style="border:1px dotted #ddd;width:100%;height:100px;line-height:100px;display:block;" href="javascript:void(0)">整行选中</a></th><!-- run:$i++ --><!-- end -->
	<!-- row:5 -->
	<!-- end -->
</tr>
</table>
<!-- if($pagelist) -->
<div align="right" style="padding-right:2px;">
{:$pagelist}
</div>
<!-- end -->

<!-- if($_SESSION[admin][editorid]==0 || $editor_btn) -->
<div class="xbutton">
  <a class="on" href="javascript:void(0);" onclick="upload();return false;">确定</a>
  <a href="javascript:void(0);" onclick="unloadme();return false;">关闭</a>
</div>
<!-- end -->

</body>
</html>